﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using CDC.SampleShell.Applications;
using CDC.SampleShell.Presentation.Controls;

namespace CDC.SampleShell.Presentation
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : CustomWindow
    {
        public MainWindow()
        {
            InitializeComponent();
            DropShadowToWindow(this);

            Version version = Assembly.GetExecutingAssembly().GetName().Version;
            tblockVersion.Text = version.ToString();

            string codeBase = Assembly.GetExecutingAssembly().CodeBase;
            UriBuilder uri = new UriBuilder(codeBase);
            string path = Uri.UnescapeDataString(uri.Path);
            string projectFileName = Path.Combine(Path.GetDirectoryName(path), Properties.Settings.Default.ProjectFilePath);
            string primaryFormName = Properties.Settings.Default.FormName;

            this.DataContext = new ProjectViewModel(projectFileName, primaryFormName);
        }

        //private void DataGrid_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
        //{
        //    // TODO: Replace this event with a command

        //    if (dgMain.SelectedItems.Count == 1)
        //    {
        //        IInputElement element = e.MouseDevice.DirectlyOver;
        //        if (element != null && element is FrameworkElement)
        //        {
        //            if (((FrameworkElement)element).Parent is DataGridCell)
        //            {
        //                EditRecord();
        //            }
        //        }
        //    }
        //}

        //private void EditRecord()
        //{
        //    Epi.Windows.Enter.EnterMainForm emf = null;

        //    RecordViewModel rvm = dgMain.SelectedItem as RecordViewModel;

        //    if (rvm != null)
        //    {
        //        rvm.EditRecordCommand.Execute(null);
        //    }
        //}
    }
}
